import { statisticTeamRiskRecordApi } from '../../api/statistic'

const initOption = () => {
  return {
    title: {
      text: '本周异常数据占比',
      left: 'center'
    },
    tooltip: {
      trigger: 'item',
      formatter: '{c}条({d}%)'
    },
    legend: {
      orient: 'vertical',
      left: 'left'
    }
  }
}
const apdaterOption = (dom) => {
  const titleFontSize = (dom.offsetWidth / 100) * 2
  return {
    title: {
      textStyle: {
        fontSize: titleFontSize
      }
    },
    legend: {
      itemWidth: titleFontSize,
      itemHeight: titleFontSize,
      itemGap: titleFontSize / 2
    }
  }
}
const dataOption = async (teamId) => {
  const { data: res } = await statisticTeamRiskRecordApi(teamId)
  return {
    series: [
      {
        type: 'pie',
        radius: '50%',
        emphasis: {
          itemStyle: {
            shadowBlur: 10,
            shadowOffsetX: 0,
            shadowColor: 'rgba(0, 0, 0, 0.5)'
          }
        },
        data: res.data
      }
    ],
    legend: {
      show: true
    }
  }
}

export { initOption, apdaterOption, dataOption }
